package com.cskaoyan.controller.admin;

import com.cskaoyan.model.admin.bo.BaseParam;
import com.cskaoyan.model.admin.bo.CommentBO;
import com.cskaoyan.model.admin.vo.BaseRespVo;
import com.cskaoyan.model.admin.vo.CommentRespVO;
import com.cskaoyan.service.admin.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName: CommentController
 * @Author: WangEnzhao
 * @Description: 商品评论模块
 * @CreateTime: 2021/12/19:39:00
 */
@RestController
@RequestMapping("admin/comment")
public class CommentController {

    @Autowired
    CommentService commentService;


    /***
    * @Author: WangEnzhao
    * @Description: 评论模块搜索
    * @CreateTime: 21:00 12/1/2021
    * @Param: [commentBO, baseParam]
    * @return: com.cskaoyan.model.admin.vo.BaseRespVo
    */
    @RequestMapping("list")
    public BaseRespVo selectComments(CommentBO commentBO, BaseParam baseParam){
        CommentRespVO commentRespVO = commentService.selectComment(commentBO, baseParam);
        return BaseRespVo.ok(commentRespVO);
    }

    /***
    * @Author: WangEnzhao
    * @Description: 删除评论
    * @CreateTime: 21:02 12/1/2021
    * @Param: [map]
    * @return: com.cskaoyan.model.admin.vo.BaseRespVo
    */
    @RequestMapping("delete")
    public BaseRespVo deleteComment(@RequestBody Map map){

        Integer id = (Integer) map.get("id");
        commentService.deleteComment(id.toString());
        return BaseRespVo.ok(null);
    }

}
